/**
 * Copyright (C), 2012-2018, 联奕科技有限公司
 * FileName: MyContraintValidator
 * Author:   石贵武
 * Date:     2018\3\7 0007 16:56
 * Description: 自定义校验
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhoudongxiu.constraint;

import com.zhoudongxiu.service.HelloService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 〈一句话功能简述〉<br>
 * 〈自定义校验〉
 *
 * @author 石贵武
 * @create 2018\3\7 0007
 * @since 1.0.0
 */
@Slf4j
public class MyContraintValidator implements ConstraintValidator<MyConstraint, Object> {


    @Autowired
    private HelloService helloService;

    @Override
    public void initialize(MyConstraint myConstraint) {
        log.info("my vaildator init");
    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
        helloService.greeting("石贵武");
        log.info("校验的值为: value = {}", value);
        return false;
    }
}